package com.campus.mapper;

import com.campus.pojo.entity.UserCourse;
import com.campus.pojo.vo.CourseVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserCourseMapper {
    @Insert("insert into user_course(user_id, course_id) values (#{userId},#{courseId})")
    void insert(UserCourse userCourse);

    /**
     * 根据用户id查询对应的课程 只要课程信息即可
     * @param userId
     * @return
     */
    List<CourseVO> getCoursesById(Long userId);

    /**
     * 根据课程id查询对应的用户id
     * @param courseId
     * @return
     */
    @Select("select user_id from user_course where course_id = #{courseId}")
    List<Long> selectStudentIdsByCourseId(Long courseId);
}
